<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" 	uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="tiles" 	uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c"		uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" 	uri="http://www.springframework.org/tags/form" %>

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>

<script type="text/javascript">

$(document).ready(function(){
    
	var gridPersonsList = $("#gridPersonsList");
	
	gridPersonsList.kendoGrid({
	    	dataSource : {
	            type     : "json",
	            transport: {
	                read: "json/listRegPersons"
	            },
	            schema   : {
	                data: ""
	            }
	        },
	        columns: [
					{
						field:"id",  							
						title: "#",
						width: 40,
						hidden: true
					},
	          		{	
						field:"idnp",  						
						title: "Cod personal",
						sortable: true,
						width: 100 , 
						template: renderIdnp
					},
					 {field: "lastName", 					title: "Familie", 					width: 100},
		             {field: "firstName", 					title: "Nume", 						width: 100},
		             {field: "phoneMob", 					title: "Telefon mobil", 			width: 90},
		             {field: "emal", 						title: "E-mail", 				width: 120},
		             {field: "skype", 						title: "Skype", 				width: 90},
		             {field: "ocupatia", 					title: "Ocupatia", 				width: 90}
	          ],
	          width : 750,
	          sortable: true,
	          pageable: {
	        	  pageSize: 15,
	        	  pageSizes: [10,15,20],
	        	  refresh: true
	          }
	    });    
	 
		function  renderIdnp (dataItem) {
			//return "<a onclick='submitPopup (" + dataItem.id + "," + dataItem.idnp +")' >" + kendo.htmlEncode(dataItem.idnp) + "</a>";
			var result = "<a href='#' onclick=\"submitPFPopup (" +  dataItem.id + " )\"  >" + kendo.htmlEncode(dataItem.idnp) + "</a>";
			//console.log(result);
			return result; 
		};  
		
		function  renderCompanyName(dataItem) {
			var result  = "";
			if (dataItem.regCompanies) {
				result = dataItem.regCompanies.companyName;
			}
			return result; 
		}; 

});

function  submitPFPopup (id) {
	//console.log ("IDDDZ = " + id);
 	//$("#pIDNP").val(id);
 	//window.parent.getRegPersonApp(4)
 	//console.log (parent);
 	var returnEn = $("#returnEntity").val();
 	if (returnEn == "ANCHETA") {
 		parent.getRegPersonApp (id);	
 	} 
 	
 	if (returnEn == "CONTRACT") {
 		parent.getRegPersonContr(id);	
 	}
 	
 	
	$("#windowClientiPFListPopup").data("kendoWindow").close();
	
};


</script>
<input id="returnEntity" type="hidden" value="${returnEntity}"/>

<div id="gridPersonsList"></div>




